package com.wx_shop.web.houtai.Controller.ShopController;


import com.alibaba.fastjson.JSONObject;
import com.wx_shop.web.houtai.Entity.shopinfo;
import com.wx_shop.web.houtai.ServiceImp.ShopImp.ShopInfoImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import com.wx_shop.web.houtai.utiltools.UploadFile;

import java.util.List;


@RequestMapping("shop")
public class ShopController {

    @Autowired
    private UploadFile uploadFile;

    @Autowired
    private ShopInfoImp shopInfoImp;



    //还没有实现注册
    @PostMapping("register")
    public JSONObject test(HttpServletRequest request) {
        String user_name = request.getParameter("user_name");
        String user_phone = request.getParameter("user_phone");
        String user_wxnum = request.getParameter("user_wxnum");
        String store_name = request.getParameter("store_name");
        String store_local = request.getParameter("store_local");

        JSONObject json = new JSONObject();

        MultiValueMap<String, MultipartFile> map =  ((MultipartHttpServletRequest) request).getMultiFileMap();
        String path = "D:/upload/file";
        json = uploadFile.UploadFile(map,path);

        return json;
    }


    //查询
    @ResponseBody
    @RequestMapping("/getAll")
    public List<shopinfo> getAll(){
        return shopInfoImp.selectAllshopinfo();
    }

    //测试
    @ResponseBody
    @RequestMapping("/getAll1")
    public void test(){
        System.out.println("hahaha");
    }




}
